<div class="row">
	<div class="col-md-12">
		<form id="iconEditForm" class="form-horizontal" action="${request.contextPath}/system/config/icon/update" method="post" onsubmit="return false">
			<input type="hidden" id="id" name="id" value="${sysIcon.id}">
			<div class="box-body">
				<div class="form-group">
					<label id="iconClazzLabel" for="iconClazz" class="col-sm-1 control-label">样式类</label>
					<div class="col-sm-5">
						<input type="text" class="form-control" name="clazz" id="iconClazz" value="${sysIcon.clazz}" placeholder="输入样式类...">
					</div>
					<label id="iconSeqLabel" for="iconSeq" class="col-sm-1  control-label">排序号</label>
					<div class="col-sm-5">
						<input  class="form-control" name="seq" id="iconSeq" type="number" value="${sysIcon.seq}" placeholder="输入排序号...">
					</div>
				</div>
				<div class="form-group">
					<label id="iconWidthLabel" for="iconWidth" class="col-sm-1 control-label">宽度</label>
					<div class="col-sm-5">
						<input type="text" class="form-control" name="width" id="iconWidth" value="${sysIcon.width}" placeholder="输入宽度...">
					</div>
					<label id="iconHeightLabel" for="iconHeight" class="col-sm-1 control-label">高度</label>
					<div class="col-sm-5">
						<input type="text" class="form-control" name="height" id="iconHeight" value="${sysIcon.height}" placeholder="输入高度...">
					</div>
				</div>
				<div class="form-group">
					<label id="iconDescriptionLabel" for="iconDescription" class="col-sm-1 control-label" >描述</label>
					<div class="col-sm-11">
						<input type="text" class="form-control" name="description" id="iconDescription" value="${sysIcon.description}" placeholder="输入描述...">
					</div>
				</div>
				<div class="form-group">
					<label id="iconRemarkLabel" for="iconRemark" class="col-sm-1 control-label">备注</label>
					<div class="col-sm-11">
						<input type="text" class="form-control" name="remark" id="iconRemark" value="${sysIcon.remark}" placeholder="输入备注...">
					</div>
				</div>
				<div class="error-message text-center" >
					<span class="error-icon"></span>
					<span id="error-msg" class="error-msg" ></span>
				</div>
             </div>
			<div class="box-footer">
				<div class="pull-right">
               		<button type="submit" class="btn btn-primary btn-sm"><i class="fa fa-paste"></i> 更新</button>
               		<button type="button" class="btn btn-default btn-sm" data-dismiss="modal"><i class="fa fa-close"></i> 关闭</button>
				</div>
          	</div>
		</form>
	</div>
</div>
<script type="text/javascript">
function ajaxSubmit(form) {
	
	var $form = $(form);
	
	if ($form.length === 1 && $form.validate()) {
        $.ajax({
            type: 'post',
            url: form.action,
            dataType: "json",
            data: $form.serialize()
        }).done(function(result){
            if (result.success) {
                $("#lgModal").modal('hide');
                alertMsg(result.message,"success");
                iconReload();
            } else {
                $form.find(".error-msg").show();
                $form.find(".error-msg").html(result.message);
            }
        });
	}
}

$(function() {
	$iconEditForm = $("#iconEditForm");
	$iconEditForm.validate({
		rules: {
            clazz: {
                required: true
            },
            width: {
                required: true
            },
            height: {
                required: true
            },
            description: {
                required: true
            },
            seq: {
                required: true
            }
		},
		messages: {
            clazz:{
                required:"样式类不能为空！"
            },
            width:{
                required:"宽度不能为空！"
            },
            height:{
                required:"高度不能为空！"
            },
            description: {
                required: "描述不能为空！"
            },
            seq: {
                required: "排序号不能为空！"
            }
		},
		submitHandler:ajaxSubmit,
		errorLabelContainer:".error-msg",
		wrapper:"li",
		showErrors:function(errorMap,errorList) {
			if(errorList.length>0){
				$iconEditForm.find(".error-msg").html(errorList[0].message);
			}else{
				$iconEditForm.find(".error-msg").html("");
			}
		},
		onkeyup: false
	});
});
</script>